<template>
  <el-col class="el-description" :lg="mdCol" :md="mdCol" :sm="smCol" :xs="24">
    <div class="term" v-if="$slots.term || term">
      <slot name="term">{{ term }}</slot>
    </div>
    <div class="detail" v-if="$slots.default">
      <slot></slot>
    </div>
  </el-col>
</template>
<style lang="scss" scoped>
.el-description {
  .term {
    // Line-height is 22px IE dom height will calculate error
    // line-height: 20px;
    padding-bottom: 16px;
    margin-right: 8px;
    color: rgba(0, 0, 0, 0.85);
    white-space: nowrap;
    display: table-cell;
    font-size: 14px;

    &:after {
      content: ':';
      margin: 0 8px 0 2px;
      position: relative;
      top: -0.5px;
    }
  }

  .detail {
    // line-height: 22px;
    width: 100%;
    padding-bottom: 16px;
    color: rgba(0, 0, 0, 0.65);
    display: table-cell;
    font-size: 14px;
  }
}
</style>
<script>
export default {
  name: 'ElDescription',
  inject: ['elDescriptionList'],
  props: {
    // eslint-disable-next-line vue/require-default-prop
    term: String
  },
  computed: {
    mdCol() {
      return 24 / this.elDescriptionList.col
    },
    smCol() {
      return (
        24 / (this.elDescriptionList.col < 2 ? this.elDescriptionList.col : 2)
      )
    }
  },
  created() {}
}
</script>
